<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<title></title>
<script type="text/javascript">
  window.onload=function (){
    document.getElementById("demo").oncontextmenu=function(){
      event.returnValue=false;
      alert("不允许使用鼠标右键！");
    }
  }
</script>
</head>

<body>
<p id="demo">
  JavaScript从入门到精通
</p>
</body>

</html>
